Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
@types/ioredis
Advanced tools
TypeScript definitions for ioredis
The @types/ioredis package provides TypeScript type definitions for the ioredis package, which is a robust, performance-focused, and full-featured Redis client for Node.js. By using @types/ioredis, developers can take advantage of TypeScript's static type checking for ioredis, ensuring that they use the ioredis API correctly.
Connecting to Redis
This code sample demonstrates how to create a new Redis client instance to connect to a Redis server using default settings.
import Redis from 'ioredis';
const redis = new Redis();
Executing Redis Commands
This code sample shows how to set a key-value pair in Redis and then retrieve the value of a key asynchronously.
redis.set('key', 'value');
redis.get('key').then(result => console.log(result));
Working with Hashes
This code sample illustrates how to work with Redis hashes by setting and getting field values within a hash.
redis.hset('hashKey', 'field', 'value');
redis.hget('hashKey', 'field').then(result => console.log(result));
Publish/Subscribe
This code sample demonstrates the publish/subscribe pattern where one Redis client publishes a message to a channel and another client subscribes to that channel to receive messages.
const publisher = new Redis();
const subscriber = new Redis();
subscriber.subscribe('channel', () => {
console.log('Subscribed to channel');
});
subscriber.on('message', (channel, message) => {
console.log(`Received message: ${message} from channel: ${channel}`);
});
publisher.publish('channel', 'Hello world!');
Transactions
This code sample shows how to use a pipeline to execute a transaction in Redis, which includes multiple commands that are executed atomically.
const pipeline = redis.pipeline();
pipeline.set('foo', 'bar');
pipeline.del('baz');
pipeline.exec().then(results => {
console.log(results);
});
The 'redis' package is a Node.js client for Redis. It provides similar functionality to ioredis but has different API design choices and lacks some advanced features like built-in cluster support and Lua scripting capabilities.
npm install --save @types/ioredis
This package contains type definitions for ioredis (https://github.com/luin/ioredis).
Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/ioredis.
These definitions were written by York Yao, Christopher Eck, Yoga Aliarham, Ebrahim, Whemoon Jang, Dmitry Motovilov, Oleg Repin, Ting-Wai To, Alex Petty, Simon Schick, Tianlin, Demian Rodriguez, Andrew Lavers, Claudiu Ceia, Asyrique, Michael Salaverry, Hannes Van De Vreken, T.J. Tarazevits, Michiel De Mey, Dae Heon Han, and Yongkyun Choi.
FAQs
Stub TypeScript definitions entry for ioredis, which provides its own types definitions
The npm package @types/ioredis receives a total of 1,515,662 weekly downloads. As such, @types/ioredis popularity was classified as popular.
We found that @types/ioredis demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.